<script lang="ts" setup>
import { loadMicroApp } from 'qiankun'

definePageMeta({
  // keepalive: true,
  key: 'subapp',
})

const app = loadMicroApp({
  name: 'hello-world',
  entry: '//localhost:8080',
  container: '#subApp',
  props: {},
}, {
  sandbox: {
    // strictStyleIsolation: true,
    experimentalStyleIsolation: true,
  },

})

console.log('subapp load', app)

onMounted(() => {
  // 加载子应用
  console.log('subapp mount', app)
  app.mount()

  onUnmounted(() => {
    console.log('subapp unmount')
    // 卸载子应用
    app.unmount()
  })
})

// onBeforeRouteUpdate ((to, from) => {
//   console.log(to, from)
// })
</script>

<template>
  <div class="">
    subApp
  </div>
  <div id="subApp" />
</template>

<style>

</style>
